package cn.edu.ren.controller;

import cn.edu.ren.pojo.Student;
import cn.edu.ren.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Collection;

/**
 * @PackageName: cn.edu.ren.controller
 * @ClassName: StudentController
 * @Description:
 * @author: RZS
 * @date: 2021/5/19  9:54
 */
@Controller
@RequestMapping("/jsp")
public class StudentController {

    @Autowired
    private IStudentService studentService;

    @GetMapping("/select_all")
    public ModelAndView selectStudentAll(){
        System.err.println("jsp");
        Collection<Student> stus = studentService.findAll();
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("index");
        modelAndView.addObject("students", stus);
        return modelAndView;
    }
}
